package org.hackystat.sensor.manual.devtime;

import java.io.Serializable;
import java.util.Date;


/**
 * A report record entry.
 * @author Shaoxuan Zhang
 *
 */
public class ReportEntry implements Serializable {
  /** Support Serialization.*/
  private static final long serialVersionUID = -5505117039998174020L;
  
  private Date startTime = new Date();
  private Date endTime = new Date();
  private String tool = "";
  private String resource = "";
  //private String labels = "";
  /**
   * @param startTime the startTime to set
   */
  protected void setStartTime(Date startTime) {
    this.startTime = startTime;
  }
  /**
   * @return the startTime
   */
  public Date getStartTime() {
    return new Date(startTime.getTime());
  }
  /**
   * @param endTime the endTime to set
   */
  protected void setEndTime(Date endTime) {
    this.endTime = endTime;
  }
  /**
   * @return the endTime
   */
  public Date getEndTime() {
    return new Date(endTime.getTime());
  }
  /**
   * @param tool the tool to set
   */
  protected void setTool(String tool) {
    this.tool = tool;
  }
  /**
   * @return the tool
   */
  public String getTool() {
    return tool;
  }
  /**
   * @param resource the resource to set
   */
  protected void setResource(String resource) {
    this.resource = resource;
  }
  /**
   * @return the resource
   */
  public String getResource() {
    return resource;
  }
  /**
   * Check if data within in instance is valid.
   * @throws ReportValidateException errors in this report instance.
   */
  public void validate() throws ReportValidateException {
    if (endTime.compareTo(startTime) <= 0) {
      throw new ReportValidateException("End time must be later than start time.");
    }
    if (tool.length() <= 0) {
      throw new ReportValidateException("Tool cannot be empty.");
    }
    if (resource.length() <= 0) {
      throw new ReportValidateException("Resource cannot be empty.");
    }
  }
}
